using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Project.EPMSync.Config.Library;

namespace Microsoft.Office.Project.EPMSync.Service.Monitor
{
    public partial class FormTraceWindow : Form
    {

        NetTraceReceiver _netTraceReceiver = null;

        public FormTraceWindow()
        {
            InitializeComponent();
            _netTraceReceiver = new NetTraceReceiver();

            _netTraceReceiver.RaiseNetTraceEvent += new EventHandler<NetTraceEventArgs>(netTraceReceiver_RaiseNetTraceEvent);
        }

        public void netTraceReceiver_RaiseNetTraceEvent(object sender, NetTraceEventArgs e)
        {
            if (e != null)
            {
                listBoxTrace.Items.Add(e.Message.Substring(0, e.Message.Length - 2));
                listBoxTrace.SelectedIndex = listBoxTrace.Items.Count - 1;
            }
        }

        private void frmTraceWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_netTraceReceiver != null)
                _netTraceReceiver.Stop();
        }


    }
}